package page.Travel;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;

import app.WebApp;
import dao.TravelDao;
import dao.UserDao;
import entity.Travel;
import entity.User;
import dao.*;
import entity.*;


public class UserListPage extends WebPage {
	public UserListPage() {
		super();

		// retrieve new instance of DAO (can be reused)
				final TravelDao dao = new TravelDao(WebApp.DATA_XML_FOLDER);

				// get list of Circle objects using DAO
				final List<Travel> allTravel = dao.getAll();

				// create "repeater" component to build rows of the "table" in output HTML
				add(new DataView<Travel>("table-rows", new ListDataProvider<Travel>(allTravel)) {
					@Override
					protected void populateItem(final Item<Travel> item) {
						final Travel travel = item.getModelObject();
						// add data for table cell in row
						item.add(new Label("id", travel.getId()));
						item.add(new Label("price", travel.getPrice()));
					item.add(new Label("type", travel.getType()));

						// add button component to open "edit" page
					/*	item.add(new Link("chooseLink") {
							@Override
							public void onClick() {
								// open "edit" page for specified Circle
								setResponsePage(new TravelPage(travel));
							}
						});*/

						// add button component to delete Circle
					/*	item.add(new Link("deleteLink") {
							@Override
							public void onClick() {
								// execute "delete" operation
								dao.delete(user.getId());
								// reload page
								setResponsePage(new TravelListPage());
							}
						});*/
					}
				});

				// add button component to open "edit" page
			/*	add(new Link("createLink") {
					@Override
					public void onClick() {
						// open "edit" page for NEW Circle
						setResponsePage(new TravelPage(new Travel()));
					}
				});*/
	}
}
